package com.itheima.Filer;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@WebFilter("/jsp/*")
public class Filer implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpSession session = ((HttpServletRequest) (servletRequest)).getSession();
        String username = (String) session.getAttribute("username");
        servletRequest.setCharacterEncoding("UTF-8");
        servletResponse.setContentType("text/plain;charset=utf-8");
        System.out.println(username+"fadsfa");
        if(username.equals(null)){
            return;
        }else {
            filterChain.doFilter(servletRequest,servletResponse);
        }
    }
}
